package com.ruoyi.app.controller.business.audit;

import com.ruoyi.business.base.PageParam;
import com.ruoyi.business.goods.domain.JbCommodity;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.web.controller.business.goods.factory.JbCommodityFactory;
import com.ruoyi.web.core.JoR;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * APP 商品 Controller
 *
 * @author ruoyi
 * @date 2024-10-11
 */
@Api("商品")
@RestController
@RequestMapping("/app/commodity")
public class AppCommodityController extends BaseController
{
    @Autowired
    private JbCommodityFactory jbCommodityFactory;

    @ApiOperation("查询商品列表")
    @GetMapping("/list")
    public TableDataInfo list(PageParam page, JbCommodity jbCommodity)
    {
        jbCommodity.setStatus("0");
        return JoR.rows(jbCommodityFactory.list(page, jbCommodity));
    }

    @ApiOperation("获取商品详细信息")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id, String deptId)
    {
        return success(jbCommodityFactory.getInfo(id, deptId));
    }

    @ApiOperation("查询产品分类树")
    @Log(title = "查询产品分类树", businessType = BusinessType.INSERT)
    @GetMapping("/listClassify")
    public AjaxResult listClassify()
    {
        return AjaxResult.success(jbCommodityFactory.listClassify());
    }

    @ApiOperation("查询商品名称和产品农药列表")
    @GetMapping("/listNameAll")
    public AjaxResult listNameAll(PageParam page, JbCommodity jbCommodity)
    {
        return success(jbCommodityFactory.listNameAll(jbCommodity));
    }

}
